package com.example.playnote.activity.ui

import android.os.Bundle
import android.text.Html
import android.text.method.LinkMovementMethod
import android.view.MenuItem
import com.example.playnote.R
import com.example.playnote.base.BaseActivity
import com.example.playnote.databinding.ActivityAboutBinding
import com.example.playnote.viewModel.HomeViewModel

class AboutActivity : BaseActivity<HomeViewModel, ActivityAboutBinding>() {

    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.toolbar.run {
            title = getString(R.string.my_about)
            setSupportActionBar(this)
            supportActionBar?.setDisplayHomeAsUpEnabled(true)
        }
        mDatabind.contentAbout.aboutVersion.text = getString(
            R.string.version_code, getString(R.string.app_name),
            packageManager.getPackageInfo(packageName, 0).versionName
        )
        @Suppress("DEPRECATION")
        mDatabind.contentAbout.aboutContent.run {
            text = Html.fromHtml(getString(R.string.about_content))
            movementMethod = LinkMovementMethod.getInstance()
        }
    }
    override fun initImmersionBar() {
        super.initImmersionBar()
        immersionBar.titleBar(R.id.toolbar).init()
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        if (item.itemId == android.R.id.home) {
            finish()
        }
        return super.onOptionsItemSelected(item)
    }

}
